$(function(){
	  var router=new VueRouter({
	 	routes:[
	  		{
				path:'/',
	  			component: {
	  				data:function(){
	  					return{
	  						lunboList:[],
	  						nowList:[],
							soonList:[],
	  					}
	  				},
	  				mounted:function(){
	  					var url = 'http://localhost:3000/lunbo?time=' + new Date().getTime();
	  					var url2='http://localhost:3000/nowList?time=' + new Date().getTime();
						var url3='http://localhost:3000/soonList?time=' + new Date().getTime();
	  					var that=this;
						this.$http.get(url).then(function(res){
						//console.log(res);
						that.lunboList=res.data.data.billboards;
						});
						this.$http.get(url2).then(function(res){
							//console.log(res.body.data.films);
							that.nowList=res.body.data.films;
						});
						this.$http.get(url3).then(function(res){
							//console.log(res);
							//console.log(new Date(res.body.data.films[0].premiereAt).getMonth()+1);
							that.soonList=res.body.data.films;
						})
	  				},
	  				updated:function(){
						var mySwiper = new Swiper ('.swiper-container', {
							autoplay : 3000,
						    loop: true,
						    simulateTouch:true,
						    autoplayDisableOnInteraction:false
					    }) ;
					},
	  				template:home
	  			}
	  		},
	  		{
	  			path:'/',
	  			component:{
	  				template:filmlist
	  			},  				
	  			children:[
	  				{
	  					path:'filmlist/nowlist',	  					
	  					component:{
	  						data:function(){
				  				return{
				  					num:1,
				  					filmlist:[]
				  				}	  					
				  			},
				  			mounted:function(){
				  				var url = 'http://localhost:3000/filmlist/nowlist?p='+this.num
				  				var that=this;
				  				this.$http.get(url).then(function(res){
				  					//console.log(res);
				  					that.filmlist=that.filmlist.concat(res.body.data.films);
				  				})
				  			},
				  			template:nowlist
	  					}
	  				},
	  				{
	  					path:'filmlist/soonlist',
	  					name:'soonlist',
	  					component:{	  						
	  						data:function(){
	  							return{
	  								num:1,
	  								soonlist:[]
	  							}
	  						},
	  						mounted:function(){
	  							var url= 'http://localhost:3000/filmlist/soonplay?p='+this.num
	  							var that=this;
	  							this.$http.get(url).then(function(res){
				  					console.log(res);
				  					console.log(that.soonlist);
				  					that.soonlist=that.soonlist.concat(res.body.data.films);
				  				})
	  						},
	  						filters:{
	  							'formatDate':function(val){
	  								var time=new Date(val);
	  								var m=time.getMonth()+1;
	  								var d=time.getDate();
	  								return m+'月'+d+'日上映';
	  							},
	  							'formatWeek':function(val){
	  								var arr=['星期一','星期二','星期三','星期四','星期五','星期六','星期日']
	  								var time=new Date(val);
	  								var w=time.getDay();
	  								return arr[w-1];
	  							}
	  						},
	  						template:soonlist
	  					}
	  				},
	  			]	  			
	  		},
	  		{
	  			path:'/film/:id',
	  			name:'detail',
	  			component:{
	  				data:function(){
	  					return{
	  						name:'',
	  						film:{}
	  					}
	  				},
	  				mounted:function(){
	  					var url = 'http://localhost:3000/'+ this.$route.params.id  + '?time=' + new Date().getTime();
	  					var that=this;
	  					this.$http.get(url).then(function(res){
	  						console.log(res);
	  						that.film=res.body.data.film;
	  					})
	  				},
	  				filters:{
	  					'formatDate':function(val){
	  						var time=new Date(val);
	  						var m=time.getMonth()+1;
	  						var d=time.getDate();
	  						return m+'月'+d+'日上映';
	  					}
	  				},	  				
	  				template:detail
	  			}
	  		},
	  		{
	  			path:'/baoanqu',
	  			component:{
	  				data:function(){
	  					return{
	  						qulist:[],
	  						cinemalist:{}
	  					}
	  				},
	  				mounted:function(){
	  					var url = 'http://localhost:3000/cinemalist?time=' + new Date().getTime();
	  					var that=this;
	  					this.$http.get(url).then(function(res){
	  						console.log(res.data.data.cinemas);
	  						var arr=res.data.data.cinemas
	  						var arrqu=[];
	  						var obj={};
	  						for(var i=0;i<arr.length;i++){
	  							if(arrqu.indexOf(arr[i].district.name)==-1){
	  								arrqu.push(arr[i].district.name)
	  							}
	  						}
	  						console.log(arrqu);
	  						that.qulist=arrqu;
	  						for(var j=0;j<arrqu.length;j++){
	  							obj[arrqu[j]]={};
	  							obj[arrqu[j]]['list']=[];
	  							if(j==0){
	  								obj[arrqu[j]]['willshow']=true;
	  							}else{
	  								obj[arrqu[j]]['willshow']=false;
	  							}
	  							for(var a=0;a<arr.length;a++){
	  								if(arr[a].district.name==arrqu[j]){
	  									//console.log(obj[arrqu[j]]);
	  									obj[arrqu[j]]['list'].push(arr[a]);
	  								}
	  							}
	  						}
	  						console.log(obj);
	  						that.cinemalist=obj
	  					})
	  				},
	  				template:allcinema
	  			}
	  		}
	  	]
	  })
	console.log(new Vue());
	var vm= new Vue({
		el:'#box',
		data:{
			show:false,
			lunboList:[],
			nowList:[],
			soonList:[],
		},
		methods:{
			changeshow:function(){
				this.show=!this.show
			}
		},
		components:{
			'v-header':{
				props: ['show'],
				// data:function(){

				// },
				methods:{
					change:function(){
						//alert(1);
						this.$emit('change');
					}
				},
				template:'#header'
			},
			'v-aside':{
				props: ['show'],
				methods:{
					change:function(){						
						this.$emit('change');
					}
				},
				template:'#aside'
			},
			// 'home':{
			// 	template:'#home'
			// }
		},
		mounted:function(){
			var url = 'http://localhost:3000/lunbo?time=' + new Date().getTime();
			var url2='http://localhost:3000/nowList?time=' + new Date().getTime();
			var url3='http://localhost:3000/soonList?time=' + new Date().getTime();

			var that=this;
			this.$http.get(url).then(function(res){
				//console.log(res);
				that.lunboList=res.data.data.billboards;
			});
			this.$http.get(url2).then(function(res){
				//console.log(res.body.data.films);
				that.nowList=res.body.data.films;
			});
			this.$http.get(url3).then(function(res){
				//console.log(res);
				console.log(new Date(res.body.data.films[0].premiereAt).getMonth()+1);
				that.soonList=res.body.data.films;
			})
		},
		// updated:function(){
		// 	var mySwiper = new Swiper ('.swiper-container', {
		// 		autoplay : 3000,
		// 	    loop: true
		//     }) ;
		// },
		router: router
	})
	//console.log(vm);
})